<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>General logging functions &mdash; GSLab Make 2.0.0 documentation</title>
      <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
      <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
      <link rel="stylesheet" href="../_static/graphviz.css" type="text/css" />
  <!--[if lt IE 9]>
    <script src="../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/sphinx_highlight.js"></script>
    <script src="../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="end_makelog" href="api/write_logs/gslab_make.write_logs.end_makelog.html" />
    <link rel="prev" title="Specifying paths" href="specifying_paths.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../index.html" class="icon icon-home">
            GSLab Make
          </a>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <p class="caption" role="heading"><span class="caption-text">Documentation</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="specifying_paths.html">Specifying paths</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">General logging functions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="api/write_logs/gslab_make.write_logs.end_makelog.html">end_makelog</a></li>
<li class="toctree-l2"><a class="reference internal" href="api/write_logs/gslab_make.write_logs.log_files_in_output.html">log_files_in_output</a></li>
<li class="toctree-l2"><a class="reference internal" href="api/write_logs/gslab_make.write_logs.start_makelog.html">start_makelog</a></li>
<li class="toctree-l2"><a class="reference internal" href="api/write_logs/gslab_make.write_logs.write_to_makelog.html">write_to_makelog</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="sourcing.html">Sourcing functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="source_logging.html">Source logging functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="program.html">Program functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="utility.html">Utility functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="repository.html">Repository functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="directory.html">Directory functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="filling.html">Filling functions</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">GSLab Make</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
      <li class="breadcrumb-item active">General logging functions</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../_sources/pages/general_logging.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <section id="general-logging-functions">
<h1>General logging functions<a class="headerlink" href="#general-logging-functions" title="Permalink to this heading"></a></h1>
<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">gslab_make</span></code> library provides functions to create a master log of activity (i.e., a <em>make log</em>) and to log information about output files. The logs are intended to facilitate the reproducibility of research.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>You must initialize make logs via <a class="reference internal" href="api/write_logs/gslab_make.write_logs.start_makelog.html#gslab_make.write_logs.start_makelog" title="gslab_make.write_logs.start_makelog"><code class="xref py py-func docutils literal notranslate"><span class="pre">start_makelog()</span></code></a> as opposed to alternative methods (e.g., manually creating a make log file). Otherwise, any attempt to call a <code class="xref py py-mod docutils literal notranslate"><span class="pre">gslab_make</span></code> function that writes to make log will raise an exception.</p>
</div>
<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">start_makelog</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">paths</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Writes file <code class="docutils literal notranslate"><span class="pre">makelog</span></code>, recording start time.
Sets make log status to boolean <code class="docutils literal notranslate"><span class="pre">True</span></code>, which is used by other functions to confirm make log exists.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The make log start condition is used by other functions to confirm a make log exists.</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>paths</strong> (<em>dict</em>) – Dictionary of paths. Dictionary should contain values for all keys listed below.</p>
</dd>
<dt class="field-even">Path Keys<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>makelog</strong> (<em>str</em>) – Path of makelog.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>None</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">end_makelog</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">paths</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Appends to file <code class="docutils literal notranslate"><span class="pre">makelog</span></code>, recording end time.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>We technically allow for writing to a make log even after the make log has ended.
We do not recommend this for best practice.</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>paths</strong> (<em>dict</em>) – Dictionary of paths. Dictionary should contain values for all keys listed below.</p>
</dd>
<dt class="field-even">Path Keys<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>makelog</strong> (<em>str</em>) – Path of makelog.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>None</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">write_to_makelog</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">paths</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">message</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Appends string <code class="docutils literal notranslate"><span class="pre">message</span></code> to file <code class="docutils literal notranslate"><span class="pre">makelog</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>paths</strong> (<em>dict</em>) – Dictionary of paths. Dictionary should contain values for all keys listed below.</p></li>
<li><p><strong>message</strong> (<em>str</em>) – Message to append.</p></li>
</ul>
</dd>
<dt class="field-even">Path Keys<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>makelog</strong> (<em>str</em>) – Path of makelog.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>None</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">log_files_in_output</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">paths</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">depth</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">inf</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Logs the following information for all files contained in directory <code class="docutils literal notranslate"><span class="pre">output_dir</span></code>.</p>
<ul class="simple">
<li><p>File name (in file <code class="docutils literal notranslate"><span class="pre">output_statslog</span></code>)</p></li>
<li><p>Last modified (in file <code class="docutils literal notranslate"><span class="pre">output_statslog</span></code>)</p></li>
<li><p>File size (in file <code class="docutils literal notranslate"><span class="pre">output_statslog</span></code>)</p></li>
<li><p>File head (in file <code class="docutils literal notranslate"><span class="pre">output_headslog</span></code>, optional)</p></li>
</ul>
<p>When walking through directory <code class="docutils literal notranslate"><span class="pre">output_dir</span></code>, float <code class="docutils literal notranslate"><span class="pre">depth</span></code> determines level of depth to walk.
Status messages are appended to file <code class="docutils literal notranslate"><span class="pre">makelog</span></code>.</p>
<p>Include additional output directories to walk through
(typically directories that you wish to keep local) in directory list <code class="docutils literal notranslate"><span class="pre">output_local_dir</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>paths</strong> (<em>dict</em>) – Dictionary of paths. Dictionary should contain values for all keys listed below.</p></li>
<li><p><strong>depth</strong> (<em>float</em><em>, </em><em>optional</em>) – Level of depth when walking through output directory. Defaults to infinite.</p></li>
</ul>
</dd>
<dt class="field-even">Path Keys<span class="colon">:</span></dt>
<dd class="field-even"><ul class="simple">
<li><p><strong>output_dir</strong> (<em>str</em>) – Path of output directory.</p></li>
<li><p><strong>output_local_dir</strong> (<em>str, list, optional</em>) – Path or list of paths of local output directories. Defaults to <code class="docutils literal notranslate"><span class="pre">[]</span></code> (i.e., none).</p></li>
<li><p><strong>output_statslog</strong> (<em>str</em>) – Path to write output statistics log.</p></li>
<li><p><strong>output_headslog</strong> (<em>str, optional</em>) – Path to write output headers log.</p></li>
<li><p><strong>makelog</strong> (<em>str</em>) – Path of makelog.</p></li>
</ul>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>None</p>
</dd>
</dl>
<p class="rubric">Example</p>
<p>The following code will log information for all files contained in
only the first level of <code class="docutils literal notranslate"><span class="pre">paths['output_dir']</span></code>.
Therefore, files contained in subdirectories will be ignored.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">log_files_in_outputs</span><span class="p">(</span><span class="n">paths</span><span class="p">,</span> <span class="n">depth</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>The following code will log information for any file in <code class="docutils literal notranslate"><span class="pre">paths['output_dir']</span></code>,
regardless of level of subdirectory.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">log_files_in_outputs</span><span class="p">(</span><span class="n">paths</span><span class="p">,</span> <span class="n">depth</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="s1">&#39;inf&#39;</span><span class="p">))</span>
</pre></div>
</div>
</dd></dl>

<div class="toctree-wrapper compound">
</div>
</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="specifying_paths.html" class="btn btn-neutral float-left" title="Specifying paths" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="api/write_logs/gslab_make.write_logs.end_makelog.html" class="btn btn-neutral float-right" title="end_makelog" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2023, Matthew Gentzkow.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>